package com.goku.gobang;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * 游戏首页
 * @author goku
 *
 */
public class MainActivity extends Activity implements OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_layout);
        findViewById(R.id.bt_aboutId).setOnClickListener(this);
        findViewById(R.id.bt_exitId).setOnClickListener(this);
        findViewById(R.id.bt_player2machine).setOnClickListener(this);
        findViewById(R.id.bt_player2player).setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_player2player:
                Intent intentOne = new Intent();
                intentOne.setClass(this, PlayersActivity.class);
                this.startActivity(intentOne);
                break;

            case R.id.bt_player2machine:
                Intent intentTwo = new Intent();
                intentTwo.setClass(this, ComputerActivity.class);
                this.startActivity(intentTwo);
                break;

            case R.id.bt_aboutId:
                openAboutDialog();
                break;

            case R.id.bt_exitId:
                finish();
                break;

            default:
                break;
        }
    }

    /**
     * 游戏帮助对话框
     */
    public void openAboutDialog() {
        AlertDialog.Builder builder = new Builder(this);
        builder.setMessage(R.string.about_text);
        builder.setTitle(R.string.about);
        builder.create().show();
    }

}
